package com.sc.nft.service;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sc.nft.entity.MetaMapSettle;
import com.sc.nft.entity.UserInfo;
import com.sc.nft.entity.UserWallet;
import com.sc.nft.entity.dto.DepositRefundDTO;
import com.sc.nft.entity.dto.MallDeductMoneyDto;
import com.sc.nft.entity.dto.MarginPaymentDTO;
import com.sc.nft.entity.dto.OperateUserWalletBatchAmountDTO;
import com.sc.nft.entity.vo.*;
import com.sc.nft.enums.ExpenditureRecordTypeEnum;
import com.sc.nft.enums.UserBalanceTypeEnum;
import com.sc.nft.enums.WalletChannelEnum;
import com.sc.nft.enums.WalletDetailTypeEnum;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

/**
 * 用户钱包表服务接口
 *
 * @author kancy
 * @description 由 Mybatisplus Code Generator 创建
 * @since 2022-08-18 01:22:40
 */
public interface UserWalletService {

    /**
     * 查询用户钱包
     *
     * @param userId)
     * @return
     */
    UserWallet getByUserId(Long userId);

    /**
     * 查询用户钱包
     *
     * @param user)
     * @return
     */
    UserWalletVO getByUser(UserInfo user, String type);

    /**
     * 转账失败
     * @param userId
     * @param amount
     * @return
     */
    void transferFail(Long userId, BigDecimal amount);
    ArrayList<UserWalletVO> getWalletList(UserInfo user);

    /**
     * 增加收益（实际到账金额=收益金额-手续费）
     *
     * @param userId  用户Id
     * @param orderNo 订单号
     * @param amount  收益金额
     * @param charge  手续费
     */
    void addIncome(Long userId, String orderNo, BigDecimal amount, BigDecimal charge, WalletDetailTypeEnum type, ExpenditureRecordTypeEnum expenditureRecordTypeEnum);
    void addPayBalanceIncome(Long userId, String orderNo, BigDecimal amount, BigDecimal charge, WalletDetailTypeEnum type, ExpenditureRecordTypeEnum expenditureRecordTypeEnum,String remark);
    void addIncome(Long userId, String orderNo, BigDecimal amount, BigDecimal charge, WalletDetailTypeEnum type, ExpenditureRecordTypeEnum expenditureRecordTypeEnum,String remark);

    /**
     * 增加收益(因杉德分账超时导致无法分账走系统余额)
     * @param userId
     * @param orderNo
     * @param amount
     * @param type
     * @param expenditureRecordTypeEnum
     * @param remark
     */
    void addSplitIncome(Long userId, String orderNo, BigDecimal amount, WalletDetailTypeEnum type, ExpenditureRecordTypeEnum expenditureRecordTypeEnum,String remark);

    /**
     * 增加收益（实际到账金额=收益金额-手续费）
     * 专供2级订单服务
     *
     * @param userId
     * @param orderNo
     * @param amount
     * @param charge
     * @param type
     * @param expenditureRecordTypeEnum
     */
    void addIncomeRemit(Long userId, String orderNo, BigDecimal amount, BigDecimal charge,BigDecimal gas, WalletDetailTypeEnum type, ExpenditureRecordTypeEnum expenditureRecordTypeEnum);






    /**
     * 资金转出
     * @param userId
     * @param amount
     * @param walletDetailType
     * @param expenditureRecordType
     */
    void transfer(Long userId, BigDecimal amount,WalletDetailTypeEnum walletDetailType,ExpenditureRecordTypeEnum expenditureRecordType);

        /**
         * 钱包支付付款 并加记录
         *
         * @param userWallet
         * @param amount
         * @param orderId
         * @return
         */
    boolean subBalance(UserWallet userWallet, BigDecimal amount, Long orderId, WalletDetailTypeEnum walletDetailTypeEnum, UserBalanceTypeEnum userBalanceTypeEnum);


    /**
     * 钱包支付付款 并加记录
     *
     * @param userWallet
     * @param amount
     * @param orderId
     * @return
     */
    boolean otherSubBalance(UserWallet userWallet, BigDecimal amount, Long orderId, WalletDetailTypeEnum walletDetailTypeEnum, UserBalanceTypeEnum userBalanceTypeEnum);

    /**
     * 钱包支付付款 并加记录,带备注版本
     *
     * @param userWallet
     * @param amount
     * @param orderId
     * @return
     */
    boolean subBalance(UserWallet userWallet, BigDecimal amount, Long orderId, WalletDetailTypeEnum walletDetailTypeEnum, UserBalanceTypeEnum userBalanceTypeEnum, String remark);

    /**
     * 保证金扣除
     *
     * @param userWallet
     * @param amount
     * @param orderId
     * @param walletDetailTypeEnum
     * @param expenditureRecordTypeEnum
     * @param remark
     * @return
     */
    boolean marginDeduction(UserWallet userWallet, BigDecimal amount, Long orderId, WalletDetailTypeEnum walletDetailTypeEnum, ExpenditureRecordTypeEnum expenditureRecordTypeEnum, String remark);

    /**
     * @description: 后台操作用户钱包余额
     * @author: rdg
     * @date: 2022/9/8 15:59
     * @param: [userTel, isType, amount]
     * @return: void
     **/
    void operateUserWallet(String userTel, Boolean isType, BigDecimal amount, String remark, UserBalanceTypeEnum userBalanceType);

    /**
     * @description: 后台查看用户钱包
     * @author: rdg
     * @date: 2022/9/13 18:06
     * @param: [userTel, pageNo, pageSize]
     * @return: com.baomidou.mybatisplus.extension.plugins.pagination.Page<com.sc.nft.entity.vo.UserWalletListVO>
     **/
    Page<UserWalletListVO> userWalletList(String userTel, int pageNo, int pageSize);

    /**
     * 获取提现详情
     *
     * @param user
     */
    GetWithdrawDetailsVO getWithdrawDetails(UserInfo user, WalletChannelEnum channel);

    /**
     * 获取提现到账金额
     *
     * @param amount
     * @return
     */
    GetWithdrawFeeVO getWithdrawAmount(String amount,Integer type,WalletChannelEnum channel);

    /**
     * 获取批量发钱的接口预览列表
     *
     * @param userMoney
     * @return
     */
    List<OperateUserWalletBatchListVO> operateUserWalletBatchList(List<OperateUserWalletBatchAmountDTO> userMoney);

    /**
     * 保证金支付
     *
     * @param marginPaymentDTO
     * @return
     */
    MarginPaymentVO marginPayment(MarginPaymentDTO marginPaymentDTO);

    /**
     * 保证金退款
     *
     * @param depositRefundDTO
     * @return
     */
    DepositRefundVO depositRefund(DepositRefundDTO depositRefundDTO);

    /**
     * 加钱 (红包)
     * @param userId
     * @param amount
     * @param balanceType
     * @param remark
     * @return
     */
    boolean addAmountByUserId(Long userId, BigDecimal amount, UserBalanceTypeEnum balanceType, String remark,WalletDetailTypeEnum type);


    /**
     * 地图分润
     * @param metaMapSettle
     */
    void mapShareProfit(MetaMapSettle metaMapSettle);

    /**
     * 获取用户余额(购物金)
     *
     * @param userId
     * @return
     */
    MallUserWalletBalance getMallUserBalance(Long userId);

    /**
     * 扣钱(购物金)
     * @param mallDeductMoneyDto
     * @return
     */
    Boolean shoppingAllowanceControls(MallDeductMoneyDto mallDeductMoneyDto);
}
